Covid Cases within the States

download.file("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv", "time_series_covid19_confirmed_US.csv", method="libcurl", timeout = 60)

covidGithub <- data.table::fread("time_series_covid19_confirmed_US.csv")

Incidence Cases Across the Pandemic

p1<-ggplot(covidGithubmelt, aes(Date, new_cases, color = county))+
  geom_line()+
  geom_point(size = .5, alpha = 0.5)+
  labs(title = 'Incidences of Covid Cases in California by County', y = 'New cases', color = 'County')
ggplotly(p1)
p1<-NULL

Incidence Cases

incidence <- plot_usmap(data = mapdf, values='new_cases', include = 'CA')+
  scale_fill_continuous(low = 'white', high = 'red', name = 'Confirmed Cases', label = scales::comma)+
  labs(title = 'Incidence Cases by California County',
       subtitle = 'Source: Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE)',
       # caption = 'As of 11/12/2020')+
       caption = paste('As of ', as.Date(max(mapdf$Date))))+
  theme(plot.title = element_text(hjust = 0.5, vjust = 0.25, size = 18), legend.position = "right",
        legend.title = element_text(size = 14), legend.text = element_text(size = 12))

Total Confirmed Cases

prevalence <- plot_usmap(data = mapdf, values='Confirmed', include = 'CA')+
  scale_fill_continuous(low = 'white', high = 'red', name = 'Confirmed Cases', label = scales::comma)+
  labs(title = 'Total Cases in California by County',
       subtitle = 'Source: Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE)',
       caption = paste('As of ', as.Date(max(mapdf$Date))))+
  theme(plot.title = element_text(hjust = 0.5, vjust = 0.25, size = 18), legend.position = "right",
        legend.title = element_text(size = 14), legend.text = element_text(size = 12))

Exploration of Covid Cases within California

Incidence Figure 1

ggplotly(incidence)

Prevalence Figure 2

prevalence

US Census data of California

CAcensus <- read_csv("data/cc-est2019-alldata-06.csv")

County Populations Within California

plot_usmap(data = Popmapdf, values='TOT_POP', include = 'CA')+
  #scale_fill_distiller(type = "seq", palette = "Spectral", direction = -1, name = "County Populations")+
  scale_fill_continuous(low = 'white', high = 'blue', name = 'Population', label = scales::comma)+
  labs(title = '2019 County Population Estimates', subtitle = 'Source: US Census')+
  theme(plot.title = element_text(hjust = 0.5, vjust = 0.25, size = 18), legend.position = "right",
        legend.title = element_text(size = 14), legend.text = element_text(size = 12))

Running Total of Confirmed Cases by Population of Counties

# Adding hoverinfo
cvd_pop%>% 
  plot_ly(x = ~TOT_POP, y = ~Confirmed,
          type = 'scatter', mode = 'markers', color = ~county,
          size = ~TOT_POP, sizes = c(5, 70), marker = list(sizemode='diameter', opacity=0.5),
          hoverinfo = 'text',
          text = ~paste( paste(county, ":", sep=""), paste(" Cases per 100k: ", per100k, sep=""),
                         paste(' Population: ', TOT_POP, sep=""), sep = "<br>"))%>%
  layout(title = "Covid Cases vs Population of Each County",
                  yaxis = list(title = "Cases per 100k"), xaxis = list(title = "Population"))

Air Quality Index

# Daily AQI for every county in California
csvAQI_data <- read_csv("data/ad_viz_plotval_data.csv")
#Visual is much better
# x-axis every other county
# csvAQI_data%>%
#   plot_ly(x = ~COUNTY, y = ~DAILY_AQI_VALUE, type = 'box', color = ~COUNTY)%>%
#   layout(title = 'Air Quality by California County', yaxis = list(title = 'AQI Value'),
#          xaxis = list(title = 'County'))

AQI%>%
  plot_ly(x = ~COUNTY, y = ~MeanAQI, type = 'box', color = ~COUNTY)%>%
  layout(title = 'Air Quality by California County', yaxis = list(title = 'AQI Value'),
         xaxis = list(title = 'County'))
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
#Could save for another visual with Covid cases on AQI daily for LA County
# AQI%>%
#   filter(COUNTY == 'Los Angeles')%>%
#   plot_ly(x = ~Date, y = ~MeanAQI,
#           type = 'scatter', mode = 'line',
#           hoverinfo = 'text',
#           text = ~paste( paste(COUNTY, ":", sep=""), paste(' Avg AQI: ', MeanAQI, sep=""),
#            paste(" Avg PM 2.5: ", MeanPM2.5, sep=""), sep = "<br>"))%>%
#   layout(title = 'LA County', yaxis = list(title = 'AQI Value'),
#          xaxis = list(title = 'Date'))